#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct student{
	int no;
	char name[32];
	char *id;
	char *tel;
	float score;
};

int main(int argc, char *argv[])
{
	struct student stu1, *p;
	
	p = &stu1;

	stu1.no = 999;
	strcpy(stu1.name,"lihua");
	stu1.id = malloc(12);
	strncpy(stu1.id, "123456879", 12);
	//stu1.tel = "19513463168";
	stu1.score = 99.9;
	

	printf("%d \n", p->no);
	printf("%s\n", p->name);
	printf("%s\n", p->id);
	//printf("%s\n", p->tel);
	printf("%.2f\n", p->score);

	free(stu1.id);
	stu1.id = NULL;

	struct student s[5];

	for(int i = 0; i < 5; i++){
		s[i].no = 99 + i;
		snprintf(s[i].name, 32, "stu%d", i);
		s[i].id  = malloc(12);
		strncpy(s[i].id, "00000000", 12);
	}
	for(int i = 0; i < 5; i++){
		printf("%d %s %s \n",s[i].no, s[i].name, s[i].id);
		free(s[i].id);
		s[i].id = NULL;
	}

	return 0;
}

